$(function(){
  // ie支持placeholder

  function iePlaceHolder(){
//  alert(0)
    if(!placeholderSupport()){   // 判断浏览器是否支持 placeholder
          $('[placeholder]').focus(function() {
              var input = $(this);
              input.next('.placeholder').hide();
              if (input.val() == input.attr('placeholder')) {
                  //input.val('');
                  //input.removeClass('placeholder');
                  input.next('.placeholder').hide();
              }
          }).blur(function() {
              var input = $(this);
              if (input.val() == '' || input.val() == input.attr('placeholder')) {
                  //input.addClass('placeholder');
                  //input.val(input.attr('placeholder'));
                  if(input.next().hasClass('placeholder')){
                    input.next().show();
                  }else{
                    input.after(
                      $('<div></div>')
                      .addClass('placeholder')
                      .text(input.attr('placeholder'))
                    );
                  }
              }
          }).blur();
      };
      function placeholderSupport() {
        return 'placeholder' in document.createElement('input');
    }
  }

  iePlaceHolder();
})
